<?php


namespace App\Service;


use App\Model\Config;
use Qiniu\Auth;

class UploadService
{
    //  七牛云获取上传token
    public function getToken()
    {
        $config = Config::where('name','image')->first();
        $config = $config->config;

        $auth = new Auth($config->access_key,$config->secret_key);

        $bucket = $config->bucket;

        // 生成上传Token
        $token = $auth->uploadToken($bucket,null,3600,[
            'returnBody' => "hash=http://image.cdn.jiabaoleshop.com/" . "$(etag)",
            'fsizeLimit'  =>    1024 * 10 * 100 * 100 * 100
        ]);
        $url = 'http://upload-z2.qiniup.com';

        return ['token' => $token,'url' => $url];
    }
}